import { Modal } from 'antd';
import PropTypes from 'prop-types';

/*
 * @Author: Eli.Chen
 * @Date: 2025-03-13 09:42:18
 * @LastEditors: Eli.Chen
 * @LastEditTime: 2025-04-11 17:07:13
 * @Description:
 */

function Dialog(props) {
    const { title, dialogOpen, onOk, onCancel, okText = '发布', cancelText = '取消', footer, children, style } = props;
    return (
        <Modal
            title={
                <div style={{ textAlign: 'center' }}>
                    {title}
                    <div
                        style={{
                            width: '100%',
                            height: '1px',
                            backgroundColor: '#e8e8e8',
                            marginTop: 8,
                        }}
                    />
                </div>
            }
            centered
            style={style}
            styles={{
                content: {
                    width: style?.width || 500,
                    height: style?.height || 500,
                    overflow: 'auto',
                },
            }}
            open={dialogOpen}
            onOk={onOk}
            onCancel={onCancel}
            okText={okText}
            cancelText={cancelText}
            footer={footer}
        >
            {children}
        </Modal>
    );
}

Dialog.propTypes = {
    title: PropTypes.node,
    dialogOpen: PropTypes.bool,
    footer: PropTypes.object,
    onOk: PropTypes.func,
    onCancel: PropTypes.func,
    children: PropTypes.element,
};

export default Dialog;
